<?php $this->load->view('layout/header'); ?>
    <script type="text/javascript">
        $(function () {
            $(".input_p1").click(function () {
                var i = $(".input_p1").index(this);
                if($(this).attr("checked"))
                    $(".input_c1").eq(i).find("input").attr("checked", true);
                else
                    $(".input_c1").eq(i).find("input").attr("checked", false);
            });
            $(".input_p").click(function () {
                var i = $(".input_p").index(this);
                if($(this).attr("checked"))
                    $(".input_c").eq(i).find("input").attr("checked", true);
                else
                    $(".input_c").eq(i).find("input").attr("checked", false);
            });
        });
    </script>
    <div id="container">
        <form method="post" action="<?php echo b_url('config/sysrole_limit_action').'/'.$sysroleid?>">
        <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_form">
            <tr class="table_form_title">
                <td colspan="4">
                    角色授权
                </td>
            </tr>
            <tr class="table_form_row">
                <td style="width: 15%" align="right">
                    角色名称：
                </td>
                <td>
                    系统管理员
                </td>
            </tr>
            <tr class="table_form_row">
                <td colspan="4">
                </td>
            </tr>
            <tr class="table_form_title">
                <td colspan="4">
                    <strong>权限分配</strong>
                </td>
            </tr>
                <?php foreach($list as $k=>$v) :?>
                    <tr class="table_form_row">
                        <td style="width: 15%" align="right">
                            <input type="checkbox" name="sysmoduleid[]" id="SysModule1" value="<?php echo $v['sysmoduleid']?>" class="input_p1" <?php $res = _checkInarray($modelids,$v['sysmoduleid']); if(TRUE == $res){ ?>checked="checked" <?php } ?>/>
                            <label for="SysModule1"><strong><?php echo $v['modulename']?></strong></label>
                        </td>
                        <td class="input_c1">
                            <?php foreach ($v['children'] as $kc=>$vc) : 
                                $ids = explode(',', $vc['syslimitids']);
                            ?>
                                    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="table_cancel">
                                        <tr>
                                            <td>
                                                <input type="checkbox" name="sysmoduleid[]" id="SysModule7" value="<?php echo $vc['sysmoduleid']?>" class="input_p"  <?php $res = _checkInarray($modelids,$vc['sysmoduleid']); if(TRUE == $res){?>checked="checked" <?php } ?>/>
                                                <label for="SysModule7"><strong><?php echo $vc['modulename']?></strong></label>
                                            </td>
                                        </tr>
                                        <tr>
                                            <td class="input_c">
                                                <?php 
                                                foreach ($ids as $key => $value){
                                                    if($value == -1 ){ continue;}
                                                ?>
                                                <span id="repSysMoudle1_ctl00_repSysMoudle2_ctl00_dlSysLimit">
                                                    <span style="display:inline-block;height:30px;width:75px;">
                                                        <?php foreach ($syslimit as $ks => $vs) { 
                                                            if($value == $vs['syslimitid']){
                                                        ?>
                                                        <input type="checkbox" value="<?php echo $vc['modulevalue'].':'.$vs['limitvalue'];?>" id="SysLimit7-1" name="limitvalue[]" <?php $res = _checkInarray($sysrolelimit,$vc['modulevalue'],$vs['limitvalue']); if(TRUE == $res){?>checked="checked"<?php }?>>
                                                        <label for="SysLimit7-1">
                                                        <?php
                                                            if($vs['syslimitid'] == $value){
                                                                echo $vs['limitname'];
                                                            }else{
                                                                continue;
                                                            }
                                                        ?>
                                                        </label>
                                                        <?php }else{
                                                            continue;
                                                            } 
                                                        }?>
                                                    </span>
                                                </span>
                                                <?php }?>
                                            </td>
                                        </tr>
                                    </table>
                            <?php endforeach ; ?>
                        </td>
                    </tr>
                <?php endforeach ; ?>
            <tr class="table_form_btn">
                <td align="right">
                    &nbsp;
                </td>
                <td colspan="3">
                    <input type="submit" name="btnSave" value="保存" id="btnSave" />
                    <input type="button" name="Submit" value="返回" onclick="javascript:history.go(-1);" />
                    <span id="errMsg" style="color:Red;"></span>
                </td>
            </tr>
        </table>
        </form>
    </div>
<?php $this->load->view('layout/footer'); ?>

